﻿using HZU.ZP.Data.Interfaces.Resume;
using HZU.ZP.Data.Models;
using HZU.ZP.Data.Models.Resume;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HZU.ZP.Data.Impl.Resume
{
    public class AwardDao:IAwardDao
    {
        private EFCoreDbContext _context;

        public AwardDao(EFCoreDbContext context)
        {
            _context = context;
        }

        public void AddAward(Award award)
        {
            _context.Awards.Add(award);
            _context.SaveChanges();
        }

        public void DeleteAward(int id)
        {
            var award = _context.Awards.FirstOrDefault(e => e.Id == id);
            _context.Awards.Remove(award);
            _context.SaveChanges();
        }

        public IList<Award> GetAwardList(int ApplicanId)
        {
            return _context.Awards.Where(e => e.ApplicantId == ApplicanId).ToList();
        }

        public void UpdateAward(Award award)
        {
            _context.Awards.Update(award);
            _context.SaveChanges();
        }
    }
}
